[JS] XMLHttpRequest problem
Posted
by mcco
on Stack Overflow
See other posts from Stack Overflow
or by mcco
Published on 2010-04-08T19:57:03Z
Indexed on
2010/04/08
20:13 UTC
Read the original article
Hit count: 410
I am trying to do "POST" with XMLHttpRequest in a firefox extension, and after that I try to get the "Location" header and open it in a new tab. For some reason, the XMLHttpRequest doesn't contain a location header.
My code
function web(url,request)
{
var http = new XMLHttpRequest();
http.open('POST',url,true);
http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
http.onreadystatechange=function() {
if(http.readyState == 2) {
alert(http.getResponseHeader("Location"));
}
}
http.send(request);
}
Also, if I change the alert to getAllResponseHeaders() to see all headers, I just don't see the location header there. If I try to spy on the request of the original site with Firebug, it does show me the location header in the response. Please help me resolve my issues. Thanks :)
P.S. I'm also unable to open a link in new tab using window.open(url, this.window.title);
, but as that's not directly related to the rest of this I'll post a separate question to ask about it.
© Stack Overflow or respective owner